<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<style>
</style>
<script type="text/javascript">
	/* function complete( flag ) {
		$("#completeFlag").val(flag);
	} */
    $(function() {
        $('#receiveDocumenthandleForm').form({
            url : '${path}/example/receiveDocument/completeTask/${taskId}',
            onSubmit : function() {
                progressLoad();
                var isValid = $(this).form('validate');
                if (!isValid) {
                    progressClose();
                }
                return isValid;
            },
            success : function(result) {
                progressClose();
                result = $.parseJSON(result);
                if (result.success) {
                    showMsg(result.msg);
                    parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
                    parent.$.modalDialog.handler.dialog('close');
                } else {
                    var form = $('#receiveDocumenthandleForm');
                    parent.$.messager.alert('错误', result.msg, 'error');
                }
            }
        });
        
        $('#receiveDocumenthandleForm [name=docType]').val('${receiveDocument.docType}');
        var val='${receiveDocument.emergencyLevel}';
 	   	$.each($('#receiveDocumenthandleForm [name=emergencyLevel]'),function(index,item){
 	   		if($(this).val()==val){
 	   			$(this).attr('checked',true);
 	   		}
 	   	})
        var val1='${receiveDocument.emergencyLevel}';
 	   	$.each($('#receiveDocumenthandleForm [name=emergencyLevel]'),function(index,item){
 	   		if($(this).val()==val1){
 	   			$(this).attr('checked',true);
 	   		}
 	   	})
    });



</script>
<div class="easyui-layout" data-options="fit:true,border:false" >
    <div data-options="region:'center',border:false" style="overflow-x:hidden;overflow-y: auto;padding: 3px;" >
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-clock icon-blue'" onclick="queryHistoryCommentFun('${receiveDocument.processInstanceId}')">历史批注</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-arrow-left icon-blue'" onclick="fallbackFun('${receiveDocument.processInstanceId}','${procDefId}','${taskId}','${taskDefKey}')">回退</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-arrow-right icon-blue'" onclick="forwardFun('${receiveDocument.processInstanceId}','${procDefId}','${taskId}','${taskDefKey}')">前进</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-comments icon-blue'" onclick="doDelegateTask()">委派</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-sound icon-blue'" onclick="doTransferTask();">转办</a>
    	<a href="${ctxPath}/task/showHisCurrentView/${taskId}" target="_blank" class="easyui-linkbutton" data-options="iconCls:'fi-photo icon-blue'">查看流程图</a>
    	<a href="javascript:;" target="_blank" class="easyui-linkbutton" data-options="iconCls:'fi-print icon-blue'">打印</a>
        <form id="receiveDocumenthandleForm" method="post">
        	<input type="hidden" name="id" value="${receiveDocument.id }" />
            <table class="grid">
            	<tr>
            		<td style="width:100px;">任务执行人</td>
            		<td>${assigneeOrCandidateUser}</td>
            	<td style="width:100px;">当前任务办理人</td>
            		<td><shiro:principal></shiro:principal></td>
            	</tr>
            	</table>
            	 <input type="hidden" name="id" value="${receiveDocument.id}">
          <input name='userName'   type='hidden' placeholder='请输入申请人' class='easyui-text-2  span2' value="<shiro:principal property="name" />" readonly="readonly">
         <input type="hidden" name="userid" value='<shiro:principal property="id" />'/>
            <table class="grid">
 				<tr>
                      <td style="text-align:right">公文类型</td>
                      <td>
                        <select name="docType" class="easyui-text-2" disabled="disabled">
                        	<option value="决议">决议</option>
                        	<option value="决定">决定</option>
                        	<option value="函">函</option>
                        </select>
                     </td>
                     <td style="text-align:right">
                     	紧急程度
                     </td>
                     <td>
                     <input type="radio" name="emergencyLevel" value="普通" disabled="disabled"/>普通
                     <input type="radio" name="emergencyLevel" value="紧急" disabled="disabled"/>紧急
                     <input type="radio" name="emergencyLevel" value="特急" disabled="disabled"/>特急
                     </td>
                  </tr>
                  <tr>
                  	<td style="text-align:right">来文时间</td>
                  	<td>
                  	 <input name='fromDate'  type='text'  class='easyui-text-2 easyui-datebox  span2 ' value="${receiveDocument.fromDate}" disabled="disabled">
                  	</td>
                  	 	<td style="text-align:right">来文字号</td>
                  	<td>
                  	<input type="text" name="docNo" class="easyui-text-2" value="${receiveDocument.docNo}" disabled="disabled"/>
                  	</td>
                  </tr>
                   <tr>
                     <td style="text-align:right">来文单位</td>
                      <td colspan="3">
                        <input name='fromUnit'   type='text' placeholder='请输入标题' class='easyui-text-2  span2' style="width:90%" value="${receiveDocument.fromUnit}" disabled="disabled">
                     </td>
                  </tr>
                   <tr>
                     <td style="text-align:right">标题</td>
                      <td colspan="3">
                        <input name='title'   type='text' placeholder='请输入标题' class='easyui-text-2  span2' style="width:90%" value="${receiveDocument.title}" disabled="disabled">
                     </td>
                  </tr>
                  
                  <tr>
                     <td style="text-align:right">正文</td>
                      <td colspan="3">
                      	<input name='contentText' id="contentText_edit"  type="hidden"/>
                      	<div id="contentText_edit_disp"></div>
                      	<a onclick="attachUpload('contentText_edit','contentText_edit_disp')" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'fi-plus icon-green'">上传文件</a>      	
                     </td>
                     </tr>
                    <tr>
                       <td style="text-align:right">附件</td>
                     <td colspan="3">
                     <input name='attachId' id="attachId_edit"  type="hidden"/>
                      	<div id="attachId_edit_disp"></div>
                      	<a onclick="attachUpload('attachId_edit','attachId_edit_disp')" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'fi-plus icon-green'">上传文件</a>      	
                     </td>
                  </tr> 
                  <tr>
                   <td style="text-align:right">审批意见</td>
                  	<td colspan="3">
                  		<textarea cols="33" rows="5" name="content" class="easyui-text-2"></textarea><br />
                  		<input type="radio" name="completeFlag"  value="true" class="input_button1" checked="checked"/>同意
            			<input type="radio" name="completeFlag"  value="false" class="input_button1"/>不同意
                  	</td>
                  </tr>
                  <c:if test="${comments.size()>0 }">
                  <tr>
                  	<td style="text-align:right">
                  		历史批注
                  	</td>
                  <td colspan="3">
                  		<c:forEach var="comment" items="${comments}">
                  			<p><b>任务名称：${comment.taskName}</b></p>
                  			<p>评论人：${comment.userName}</p>
                  			<p>评论时间：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${comment.time}"/></p>
                  			<p>评论内容：${comment.comment}</p>
                  		</c:forEach>
                  	</td>
                  </tr>
                  </c:if>
            </table>
        </form>
    </div>
</div>